package org.dlsu.mt;

import org.dlsu.mt.parser.Word;

/**
 * A simple morphological analyzer that removes the "s" from the original word
 */
public class SimpleMorphAnalyzer implements MorphInterface
{
	/**
	 * Gets the root word by removing the "s"
	 *
	 * @param word The word to get the root as a Word object
	 * @return Returns a Word object representing the word without the "s" as the root word
	 */
	public Word getRoot(Word word )
	{
		String originalWord = word.getWholeWord();

		if (originalWord.endsWith("s"))
			word.setRootWord(originalWord.substring(0 , originalWord.length()-1));

		return word;
	}

	/**
	 * Gets the root word by removing the "s"
	 *
	 * @param inputWord The word to get the root as a string
	 * @return Returns a Word object representing the word without the "s" as the root word
	 */
	public Word getRoot(String inputWord)
	{
		Word word = new Word(inputWord);
		return getRoot(word);

	}
}